<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>select - Database - Prails API Documentation</title>
    </head>
    <body>
        <h3 class="P4"><a name="_SelectQuery"><span/></a>select</h3><h4 class="Heading_20_4"><a name="_Description_"><span/></a>Description:</h4>
        <p class="Text_20_body">
            A SQL select is executed on the specified tables.
        </p>
        <h4 class="Heading_20_4"><a name="_Syntax_"><span/></a>Syntax:</h4>
        <p class="Text_20_body">
            <code>Array select($str_table, $mix_filter, $str_sort)</code><br/>
            <code>Array get($str_table, $mix_filter, $str_sort)</code>
        </p>
        <table border="0" cellspacing="0" cellpadding="0" class="Table15">
            <colgroup>
                <col width="117"/><col width="626"/>
            </colgroup>
            <tr>
                <td style="text-align:left;width:2.683cm; " class="Table15_A1">
                    <p class="Table_20_Contents">
                        $str_table
                    </p>
                </td>
                <td style="text-align:left;width:14.316cm; " class="Table15_B1">
                    <p class="P1">
                        the table from which to select data from (for selects involving more than one table, please use <a href="Database.query.html"><code>query()</code></a>)
                    </p>
                </td>
            </tr>
            <tr>
                <td style="text-align:left;width:2.683cm; " class="Table15_A2">
                    <p class="Table_20_Contents">
                        $mix_filter
                    </p>
                </td>
                <td style="text-align:left;width:14.316cm; " class="Table15_B2">
                    <p class="Table_20_Contents">
                    	Either an array like: <code>Array("fieldname1" => "fieldvalue1", "fieldname2" => "fieldvalue2", ...)</code>
                    	or a SQL condition to be applied                        
                    </p>
                </td>
            </tr>
            <tr>
                <td style="text-align:left;width:2.683cm; " class="Table15_A2">
                    <p class="Table_20_Contents">
                        $str_sort
                    </p>
                </td>
                <td style="text-align:left;width:14.316cm; " class="Table15_B2">
                    <p class="Table_20_Contents">
                        sorting rule to be used; consists of at least the field name to be sorted and optionally the sorting direction ("ASC" for ascending or "DESC" for descending).
                        Multiple fields can be used for sorting; those need to be seperated by comma. 
                    </p>
                </td>
            </tr>
        </table>
        <h4 class="Heading_20_4"><a name="_Example_"><span/></a>Example:</h4>
        <p class="Text_20_body">This example will select all entries from the table "user" which have a photo set and sorts them descending by the fields "last_name" and "first_name".
		</p><pre>        
            $arr_result = $this->select("user", "NOT ISNULL(photo)", "last_name DESC, first_name DESC");
        </pre>
        <p class="Text_20_body"><code>$arr_result</code> will look like this:
        </p>
        <pre>
            $arr_result = Array(
                Array(
                    "user_id" => "4",
                    "last_name" => "Zathura",
                    "first_name" => "Adam",
                    "photo" => "test.jpg"
                ),
                Array(
                    "user_id" => "19",
                    "last_name" => "Yween",
                    "first_name" => "Zelda",
                    "photo" => "mypicture.jpg",
                ),
                ...
            );
		</pre>
    </body>
</html>
